package fr.emse.tatiana.replayable;

import java.util.Hashtable;

import org.eclipse.swt.graphics.Color;

public class ReplayableEvent implements Comparable<ReplayableEvent> {

	private Anchor anchor;
	private long time;
	private long duration;
	private Hashtable<Integer,Object> facets;
	private Hashtable<Integer,Color> colors;
	
	public ReplayableEvent(long time, long duration, Anchor anchor) {
		this.time = time;
		this.duration = duration;
		this.anchor = anchor;
		this.facets = new Hashtable<Integer, Object>();
		this.colors = new Hashtable<Integer, Color>();
	}
	
	/**
	 * @return the anchor
	 */
	public Anchor getAnchor() {
		return anchor;
	}
	/**
	 * @return the time
	 */
	public long getTime() {
		return time;
	}
	
	/**
	 * @return the duration
	 */
	public long getDuration() {
		return duration;
	}
	
	public long getEndTime() {
		return time+duration;
	}
	
	public Object getFacet(int id) {
		return facets.get(id);
	}
	
	public void setFacet(int facet, Object value) {
		if (value==null) {
			value = "";
		}
		facets.put(facet, value);
	}

	public int compareTo(ReplayableEvent o) {
		if (o.time<this.time) {
			return 1;
		}
		if (o.time>this.time) {
			return -1;
		}
		return 0;
	}

	public void setFacetColor(int facet, Color color) {
		if (color == null) return;
		colors.put(facet, color);
	}
	
	public Color getFacetColor(int facet) {
		return colors.get(facet);
	}
	
}
